﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace shfa.snomtastic.data.business
{
    public class AppConfig 
    {
        public IDictionary<string,string> Items { get; set; }

        public AppConfig()
        {
            AppConfigController acc = new AppConfigController();
            List<AppConfigInfo> aciList = acc.SelectAppConfigs();

            this.Items = new Dictionary<string,string>();
            foreach (AppConfigInfo aci in aciList)
            {
                this.Items.Add(aci.Name, aci.Value);
            }

        }


        public string GetItemValue(string key)
        {
            if (this.Items.ContainsKey(key))
            {
                return this.Items[key];
            }
            else
            {
                AppConfigController acc = new AppConfigController();
                acc.InsertAppConfig(new AppConfigInfo(key,string.Empty));
                this.Items.Add(key, string.Empty);
                return string.Empty;
            }
            
        }



    }
}
